//
//  CustomTableViewCell.m
//  10-TableViewCellSelf-Size
//
//  Created by 曹曹 on 16/7/27.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "CustomTableViewCell.h"
#import "UIView+Frame.h"

@interface CustomTableViewCell ()
@property (nonatomic, strong) UILabel *newsLabel;
@end

@implementation CustomTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _newsLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _newsLabel.numberOfLines = 0;
        [self.contentView addSubview:_newsLabel];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    // 使用cell的高度(不是contentView的高度)给label去赋值
    _newsLabel.frame = CGRectMake(0, 0, self.contentView.gx_width, self.gx_height);
    // contentView会给分割线预留0.5的距离
    NSLog(@"%lf---%lf", self.contentView.gx_height, self.gx_height);
}

- (void)setString:(NSString *)string {
    _string = [string copy];
    _newsLabel.text = _string;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
